//package com.zmn.plat.admin.controller.channel;
//
//import com.alibaba.fastjson.JSONObject;
//import com.aliyun.openservices.shade.com.google.common.collect.Lists;
//import com.zmn.common.constant.GlobalConsts;
//import com.zmn.common.constant.StatusConsts;
//import com.zmn.common.dictionary.GlobalDict;
//import com.zmn.common.dto.KvDTO;
//import com.zmn.common.dto.VtDTO;
//import com.zmn.common.dto2.ResponseDTO;
//import com.zmn.common.utils.collection.CollectionUtil;
//import com.zmn.common.utils.date.DateUtil;
//import com.zmn.common.utils.number.NumberUtil;
//import com.zmn.common.utils.string.StringUtil;
//import com.zmn.common.utils.validator.ValidateResult;
//import com.zmn.common.utils.validator.ValidatorUtil;
//import com.zmn.mcc.cas.model.LoginStaff;
//import com.zmn.mcc.common.dto.dept.DeptDRO;
//import com.zmn.mcc.permit.mysql.cache.DPermitCache;
//import com.zmn.plat.common.dictionary.ChannelAccessIdentityEnum;
//import com.zmn.plat.common.dictionary.ChannelCityRatioTypeEnum;
//import com.zmn.plat.common.dictionary.PlatEnum;
//import com.zmn.plat.common.exception.PlatException;
//import com.zmn.plat.manager.dictionary.ChannelDict;
//import com.zmn.plat.manager.dictionary.ProductDict;
//import com.zmn.plat.model.entity.channel.*;
//import com.zmn.plat.model.entity.channel.commission.settle.rule.ChannelCommissionSettleRule;
//import com.zmn.plat.model.entity.channel.order.config.ChannelOrderConfig;
//import com.zmn.plat.model.entity.servcategory.ServAssCategoryQuery;
//import com.zmn.plat.model.entity.servcategory.ServCategory;
//import com.zmn.plat.model.vo.channel.ChannelCityPriceRatioVo;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang.StringUtils;
//import org.apache.shiro.authz.annotation.Logical;
//import org.apache.shiro.authz.annotation.RequiresPermissions;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.BeanUtils;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest;
//import java.util.*;
//import java.util.stream.Collectors;
//
///**
// * 渠道ModifyController
// *
// * @author xiangjunming
// * @since 2019 /08/20 15:11:50
// */
//@Slf4j
//@Controller
//@RequestMapping("/channel/")
//public class ChannelModifyController extends ChannelBaseController {
//
//    private Logger logger = LoggerFactory.getLogger(ChannelModifyController.class);
//
//    @Resource
//    DPermitCache dPermitCache;
//
//
//    @RequestMapping(value = "/clearCache")
//    @ResponseBody
//    public ResponseDTO clearCache() {
//        dPermitCache.clear();
//        return ResponseDTO.success();
//    }
//
//    @RequestMapping(value = "/initSendMQSettle")
//    @ResponseBody
//    public ResponseDTO initSendMQSettle() {
//        if (!channelBService.initSendMQSettle(getMcStaff().getRealName())) {
//            return ResponseDTO.fail("初始发送MQ结算失败");
//        }
//        return ResponseDTO.success(true, "初始发送MQ结算成功");
//    }
//
//    @RequestMapping(value = "updateSort")
//    @ResponseBody
//    public ResponseDTO updateSort(HttpServletRequest request, @RequestParam(value = "id", defaultValue = "0") Integer channelId,
//                                  @RequestParam(value = "sort", defaultValue = "0") Integer sort) {
//
//        if (channelId == 0) {
//            return ResponseDTO.fail("请选择要更改排序的渠道！");
//        }
//        if (sort == 0) {
//            return ResponseDTO.fail("请设置渠道排序值！");
//        }
//
//        channelBService.updateSortByKey(channelId, sort, getMcStaffRealName());
//        return ResponseDTO.success(StatusConsts.STATUS_SUCCESS, GlobalConsts.SUCCESS_MSG);
//    }
//
//    /**
//     * 启用/停用
//     *
//     * @param ids    the ids
//     * @param status the status
//     * @return the result dto
//     * @author xiangjunming
//     * @modifier yangshuangping 2021/6/15 16:17:29 一级渠道下最后一个二级渠道关闭时，主动关闭对应一级渠道
//     * @since 2019/9/5
//     */
//    @RequestMapping(value = "modifyStatus")
//    @RequiresPermissions("/channel/updateStatus.action")
//    @ResponseBody
//    public ResponseDTO updateStatus(String ids, int status) {
//        if (StringUtil.isBlank(ids)) {
//            return ResponseDTO.fail("请选择渠道！");
//        }
//        List<Integer> channelIds = StringUtil.convertStrsToList(ids);
//        // 启用校验
//        if (status == GlobalDict.STATUS_ENABLE) {
//            // 服务分类ID
//            List<Integer> allServCategoryIds = getServCategoryList().stream().map(ServCategory::getCategId).collect(Collectors.toList());
//            for (Integer channelId : channelIds) {
//                Channel channel = channelService.findByKey(channelId);
//                ChannelSettle channelSettle = Optional.ofNullable(channelSettleService.findByKey(channelId)).orElse(new ChannelSettle());
//                ChannelOrderConfig channelOrderConfig = Optional.ofNullable(channelOrderConfigService.findByKey(channelId)).orElse(new ChannelOrderConfig());
//                ChannelCommissionSettleRule channelCommissionSettleRule = Optional.ofNullable(channelCommissionSettleRuleService.findByChannelId(channelId)).orElse(new ChannelCommissionSettleRule());
//                if (channel == null) {
//                    return ResponseDTO.fail(String.format("渠道信息不存在! %s", channelId));
//                }
//                // 校验二级渠道
//                if (channel.getRank() == ChannelDict.RANK_TWO) {
//                    ValidateResult validator = ValidatorUtil.validator(channel);
//                    if (!validator.isSuccess()) {
//                        return ResponseDTO.fail(String.format("%s:请维护%s! ", channel.getName(), Arrays.toString(validator.getErrMsg())));
//                    }
//
//                    if (Objects.equals(channel.getChannelType(), com.zmn.plat.common.dictionary.ChannelTypeEnum.CONSTS_CJ)) {
//                        if (channelOrderConfig.getInReceivablesLimit() == null) {
//                            return ResponseDTO.fail(String.format("%s:请维护保内收款限制! ", channel.getName()));
//                        }
//                    }
//
//                    validator = ValidatorUtil.validator(channelSettle);
//                    if (!validator.isSuccess()) {
//                        return ResponseDTO.fail(String.format("%s:请维护%s! ", channel.getName(), Arrays.toString(validator.getErrMsg())));
//                    }
//
//                    // 身份为渠道校验
//                    if (channel.getAccessIdentity() != null
//                            && channel.getAccessIdentity().contains(String.valueOf(ChannelAccessIdentityEnum.CONSTS_CHANNEL))) {
//                        if (channelCommissionSettleRule.getSettle() == null || channelCommissionSettleRule.getSettle() == GlobalConsts.NONE) {
//                            return ResponseDTO.fail(String.format("%s:请维护是否结算佣金! ", channel.getName()));
//                        }
//                        if (channelCommissionSettleRule.getSettle() == GlobalConsts.YES) {
//                            if (channelCommissionSettleRule.getDeduct() == null || channelCommissionSettleRule.getDeduct() == GlobalConsts.NONE) {
//                                return ResponseDTO.fail(String.format("%s:请维护是否坐扣! ", channel.getName()));
//                            }
//
//                            // 校验佣金配置
//                            List<ChannelCommission> commissions = commissionService.listByChannelId(channelId);
//                            if (commissions == null || commissions.size() == 0) {
//                                return ResponseDTO.fail(String.format("%s:请完成全部服务分类佣金比例配置! ", channel.getName()));
//                            }
//
//                            List<Integer> servCategIds = commissions.stream().filter(p -> p.getCommissionCurrent() != null)
//                                    .map(ChannelCommission::getServCategId).collect(Collectors.toList());
//                            boolean flag = allServCategoryIds.stream().allMatch(p -> servCategIds.contains(p));
//                            if (!flag) {
//                                return ResponseDTO.fail(String.format("%s:请完成全部服务分类佣金比例配置! ", channel.getName()));
//                            }
//                        }
//                    }
//
//                    // 身份为客户校验
//                    if (channel.getAccessIdentity() != null
//                            && channel.getAccessIdentity().contains(String.valueOf(ChannelAccessIdentityEnum.CONSTS_CUSTOMER))) {
//                        ChannelSettle settle = channelSettleService.findByKey(channelId);
//                        if (settle == null || StringUtil.isBlank(settle.getFinancer()) || StringUtil.isBlank(settle.getFinancerPhone())) {
//                            return ResponseDTO.fail(String.format("%s:请维护-结算信息-渠道方财务对接人/电话! ", channel.getName()));
//                        }
//                    }
//
//                    Channel parent = channelService.findByKey(channel.getParentId());
//                    if (parent.getStatus() != GlobalConsts.YES) {
//                        return ResponseDTO.fail(String.format("一级渠道%s为禁用状态，请启用后再操作", parent.getName()));
//                    }
//                }
//            }
//
//        } else {
//            // 当为二级渠道时需要关闭一级渠道
//            List<Integer> oneChannelIds = Lists.newArrayList();
//            for (Integer channelId : channelIds) {
//                // 禁用校验
//                Channel channel = channelService.findByKey(channelId);
//                if (channel == null) {
//                    return ResponseDTO.fail(String.format("渠道信息不存在! %s", channelId));
//                }
//                if (channel.getRank() == ChannelDict.RANK_ONE) {
//                    // 校验禁用一级渠道
//                    Integer count = channelService.countByQuery(new ChannelQuery() {
//                        {
//                            setParentId(channel.getChannelId());
//                            setStatus(GlobalConsts.YES);
//                        }
//                    });
//                    if (count > 0) {
//                        return ResponseDTO.fail(String.format("%s:二级渠道部分为启用状态，请全部关闭后在操作", channel.getName()));
//                    }
//                }
//                // 一级渠道下最后一个二级渠道关闭时，主动关闭对应一级渠道
//                if (channel.getRank() == ChannelDict.RANK_TWO) {
//                    // 需要过滤掉当前二级渠道
//                    Long count = channelService.listByParentId(channel.getParentId()).stream()
//                            // 过滤状态为开启中
//                            .filter(channel1 -> channel1.getStatus() == GlobalConsts.YES)
//                            // 排除当前要关闭的渠道
//                            .filter(channel1 -> channelIds.indexOf(channel1.getChannelId()) == -1).count();
//                    if (count == 0) {
//                        oneChannelIds.add(channel.getParentId());
//                    }
//                }
//            }
//            channelIds.addAll(oneChannelIds);
//        }
//        channelBService.modifyStatusByIds(channelIds.stream().distinct().collect(Collectors.toList()), status,
//                getMcStaff().getRealName());
//        return ResponseDTO.success(StatusConsts.STATUS_SUCCESS, "操作成功！");
//    }
//
//    @RequestMapping(value = "updateOrderLink")
//    @ResponseBody
//    public ResponseDTO updateOrderLink(@RequestParam(value = "channelId", defaultValue = "") Integer channelId,
//                                       @RequestParam(value = "orderLink", defaultValue = "") String orderLink) {
//        if (StringUtil.isBlank(orderLink)) {
//            return ResponseDTO.fail("百度API链接不能为空！");
//        }
//
//        Channel channel = Optional.ofNullable(channelService.findByKey(channelId)).orElse(new Channel());
//        channel.setChannelId(channelId);
//        channel.setOrderLink(orderLink);
//        channel.setUpdater(getMcStaffRealName());
//        channel.setUpdateTime(DateUtil.getNow());
//
//        channelService.updateByKeySelective(channel);
//        return ResponseDTO.success(true, "操作成功！");
//    }
//
//    /**
//     * 新增/修改渠道
//     *
//     * @param addVO the channel new
//     * @return the result dto
//     * @since 2019/9/5
//     */
//    @RequestMapping("addEdit")
//    @RequiresPermissions(value = {"/channel/addEdit.action", "/channel/add.action"}, logical = Logical.OR)
//    @ResponseBody
//    public ResponseDTO addEdit(@RequestBody ChannelAddVO addVO) {
//
//        Channel channel = new Channel();
//        BeanUtils.copyProperties(addVO, channel);
//        channel.setName(StringUtils.trim(addVO.getName()));
//        channel.setInnerName(StringUtils.trim(addVO.getInnerName()));
//
//
//        if (StringUtil.isNotBlank(addVO.getContractTimeRange())) {
//            String[] contractTimeRange = addVO.getContractTimeRange().split(" - ");
//            if (contractTimeRange != null && contractTimeRange.length == 2) {
//                Date contractStartDate = DateUtil.dateFormatToDate(contractTimeRange[0], DateUtil.FORMAT_DATE3);
//                Date contractExpiresDate = DateUtil.dateFormatToDate(contractTimeRange[1], DateUtil.FORMAT_DATE3);
//                channel.setContractStartDate(contractStartDate);
//                channel.setContractExpiresDate(contractExpiresDate);
//            }
//        }
//
//        String lable = NumberUtil.isNullOrZero(channel.getChannelId()) ? "新增渠道" : "修改渠道";
//
//        if (StringUtil.isBlank(channel.getName())) {
//            return ResponseDTO.fail("请填写渠道名称！");
//        }
//        try {
//            LoginStaff mcStaff = getMcStaff();
//            PlatEnum plat = PlatEnum.getEnumByPlat(channel.getPlat());
//            channel.setOrgId(plat.organId);
//            Integer newChannelId = 0;
//
//            if (NumberUtil.isNotNullOrZero(channel.getDeptId())) {
//                ResponseDTO<DeptDRO> dept = deptListRemoteService.getDept(channel.getDeptId());
//                if (dept.isSuccess() && Objects.nonNull(dept.getData()) && NumberUtil.isNotNullOrZero(dept.getData().getParentId()) && dept.getData().getParentId() > 1) {
//                    ResponseDTO<DeptDRO> parentDept = deptListRemoteService.getDept(dept.getData().getParentId());
//                    if (parentDept.isSuccess() && Objects.nonNull(parentDept.getData())) {
//                        channel.setOneDeptId(parentDept.getData().getDeptId());
//                        channel.setOneDeptName(parentDept.getData().getDeptName());
//                    }
//                }
//            }
//
//            if (NumberUtil.isNullOrZero(channel.getChannelId())) {
//                channel.setCreater(mcStaff.getRealName());
//                channel.setUpdater(mcStaff.getRealName());
//                ChannelAddVO createChannel = new ChannelAddVO();
//                BeanUtils.copyProperties(channel, createChannel);
//                channelBService.addChannel(createChannel, mcStaff);
//                newChannelId = createChannel.getChannelId();
//            } else {
//                newChannelId = channel.getChannelId();
//                channel.setUpdater(mcStaff.getRealName());
//                channelBService.modifyBaseInfoByKey(channel, mcStaff);
//            }
//
//            return ResponseDTO.success(newChannelId, String.format("%s成功！", lable));
//
//        } catch (PlatException e) {
//            return ResponseDTO.fail(e.getMessage());
//        } catch (Exception e) {
//            logger.error("error:", e);
//            return ResponseDTO.fail(String.format("%s失败！", lable));
//        }
//    }
//
//    /**
//     * 描述: 复制渠道
//     *
//     * @param
//     * @return
//     * @author guoqiao
//     * @since 2021/6/7 16:53
//     */
//    @RequestMapping(value = "add/copyChannel")
//    @ResponseBody
//    public ResponseDTO copyChannel(@RequestBody ChannelCopy copy) {
//
//        try {
//            channelCopyBService.copyChannel(copy, getMcStaff());
//            return ResponseDTO.success();
//        } catch (Exception e) {
//            logger.error("复制渠道失败,原因:{}", e.getMessage(), e);
//            return ResponseDTO.fail("复制渠道失败," + e.getMessage());
//        }
//    }
//
//    /**
//     * 配置渠道内部名称
//     *
//     * @param channelId the channel id
//     * @param innerName the innerName
//     * @return the result dto
//     * @author xiangjunming
//     * @since 2020/06/10
//     */
//    @RequestMapping("configInnerName")
//    @RequiresPermissions(value = {"/channel/configInnerName.action"})
//    @ResponseBody
//    public ResponseDTO configInnerName(Integer channelId, String innerName) {
//        String lable = "配置渠道内部名称";
//        try {
//            LoginStaff mcStaff = getMcStaff();
//            Channel channel = new Channel();
//            channel.setChannelId(channelId);
//            channel.setInnerName(innerName);
//            channel.setUpdater(mcStaff.getRealName());
//            channelBService.updateInnerName(channel);
//
//            return ResponseDTO.success(channelId, String.format("%s成功！", lable));
//
//        } catch (PlatException e) {
//            return ResponseDTO.fail(e.getMessage());
//        } catch (Exception e) {
//            logger.error("error:", e);
//            return ResponseDTO.fail(String.format("%s失败！", lable));
//        }
//    }
//
//    /**
//     * 修改渠道订单配置
//     *
//     * @param channelOrderConfig the channel new
//     * @return the result dto
//     * @author xiangjunming
//     * @modify linfeng 渠道订单配置表从渠道表独立出来
//     * @since 2019/9/5
//     */
//    @RequestMapping("modifyOrderConfig")
//    @RequiresPermissions(value = {"/channel/orderConfig/addEdit.action", "/channel/add.action"}, logical = Logical.OR)
//    @ResponseBody
//    public ResponseDTO modifyOrderConfig(@RequestBody ChannelOrderConfig channelOrderConfig) {
//        String lable = "修改渠道订单配置";
//        try {
//            channelBService.modifyOrderConfig(channelOrderConfig);
//
//            return ResponseDTO.success(channelOrderConfig.getChannelId(), String.format("%s成功！", lable));
//
//        } catch (Exception e) {
//            logger.error("error:", e);
//            return ResponseDTO.fail(String.format("%s失败！", lable));
//        }
//    }
//
//    /**
//     * 保存服务分类
//     *
//     * @param channelId  the channel id
//     * @param showType   产品分类 1后台 2前台
//     * @param categoryId the category id
//     * @return the result dto
//     * @author xiangjunming
//     * @since 2019/9/5
//     */
//    @RequestMapping("saveServiceCategory")
//    @RequiresPermissions(value = {"/channel/serviceCategory/addEdit.action", "/channel/add.action"}, logical = Logical.OR)
//    @ResponseBody
//    public ResponseDTO saveServiceCategory(Integer channelId, Integer servCategId, Integer switchStatus, Integer showType,
//                                           String categoryId) {
//        String lable = "保存服务分类";
//        try {
//            if (channelId == null) {
//                return ResponseDTO.fail("渠道ID不能为空！");
//            }
//
//            if (servCategId == null) {
//                return ResponseDTO.fail("服务分类ID不能为空！");
//            }
//
//            List<String> ids = StringUtil.isBlank(categoryId) ? Collections.EMPTY_LIST : Arrays.asList(categoryId.split(","));
//            channelBService.modifyChannelServiceCategory(channelId, servCategId, switchStatus, showType, ids, getMcStaff().getRealName());
//            return ResponseDTO.success(channelId, String.format("%s成功！", lable));
//        } catch (PlatException e) {
//            return ResponseDTO.fail(e.getMessage());
//        } catch (Exception e) {
//            logger.error("error:", e);
//            return ResponseDTO.fail(String.format("%s失败！", lable));
//        }
//    }
//
//    /**
//     * 修改渠道佣金
//     *
//     * @param commission the commission
//     * @return the result dto
//     * @author xiangjunming
//     * @since 2019/9/5
//     */
//    @RequestMapping("modifyCommission")
//    @RequiresPermissions(value = {"/channel/commission/addEdit.action", "/channel/add.action"}, logical = Logical.OR)
//    @ResponseBody
//    public ResponseDTO modifyCommission(@RequestBody ChannelCommission commission) {
//        String lable = "修改渠道佣金";
//        try {
//            String realName = getMcStaff().getRealName();
//            Integer channelId = commission.getChannelId();
//            if (channelId == null) {
//                return ResponseDTO.fail("渠道ID不能为空");
//            }
//            if (Objects.equals(commission.getCommissionTypeNew(), GlobalConsts.YES)) {
//                // 元转分
//                commission.setCommissionNew(commission.getCommissionNew() * 100);
//            }
//            if (commission.getServCategId() == null) {
//                List<ServCategory> servCategoryList = getServCategoryList();
//                List<ChannelCommission> list = servCategoryList.stream().map(servCategory -> {
//                    ChannelCommission cc = new ChannelCommission();
//                    BeanUtils.copyProperties(commission, cc);
//                    cc.setServCategId(servCategory.getCategId());
//                    cc.setServCategName(servCategory.getName());
//                    return cc;
//                }).collect(Collectors.toList());
//                channelBService.modifyCommissions(list, realName);
//            } else {
//                channelBService.modifyCommission(commission, realName);
//            }
//            return ResponseDTO.success(channelId, String.format("%s成功！", lable));
//
//        } catch (Exception e) {
//            logger.error("error:", e);
//            return ResponseDTO.fail(String.format("%s失败！", lable));
//        }
//    }
//
//    /**
//     * 描述: 根据服务分类id查询一级分类数据
//     *
//     * @param value 服务分类id
//     * @return java.util.List<com.zmn.common.dto.VtDTO>
//     * @author wangjie
//     * @since 2019/8/23
//     **/
//    @ResponseBody
//    @RequestMapping(value = "loadCategByServId")
//    public List<VtDTO> loadCategByServId(@RequestParam(value = "value", defaultValue = "0") Integer value) {
//
//        ServAssCategoryQuery query = new ServAssCategoryQuery();
//        query.setServCategId(value);
//        query.setCategOneStatus(GlobalConsts.YES);
//        List<KvDTO<Integer, String>> items = servAssCategoryService.listCateOneByQuery(query);
//        return Optional.ofNullable(servAssCategoryService.listCateOneByQuery(query)).orElse(Collections.emptyList()).stream()
//                .map(mm -> new VtDTO(mm.getKey(), mm.getValue())).collect(Collectors.toList());
//    }
//
//    /**
//     * 保存结算信息
//     *
//     * @param channelSettle the channel settle
//     * @return the result dto
//     * @author xiangjunming
//     * @since 2019/9/5
//     */
//    @RequestMapping("saveSettle")
//    @RequiresPermissions(value = {"/channel/settle/addEdit.action", "/channel/add.action"}, logical = Logical.OR)
//    @ResponseBody
//    public ResponseDTO saveSettle(@RequestBody ChannelSettle channelSettle) {
//        String lable = "保存结算信息";
//        try {
//            Integer channelId = channelSettle.getChannelId();
//            if (channelId == null) {
//                return ResponseDTO.fail("渠道ID不能为空");
//            }
//            channelBService.modifySettle(channelSettle, getMcStaff().getRealName());
//            return ResponseDTO.success(String.valueOf(channelId), String.format("%s成功！", lable));
//
//        } catch (Exception e) {
//            logger.error("error:", e);
//            return ResponseDTO.fail(String.format("%s失败！", lable));
//        }
//    }
//
//    /**
//     * 收退款押金
//     *
//     * @param channelId the channel id
//     * @param type      the type
//     * @param amount    the amount
//     * @param remark    the remark
//     * @return the result dto
//     * @author xiangjunming
//     * @since 2019/9/5
//     */
//    @RequestMapping("inOutDeposit")
//    @RequiresPermissions(value = {"/channel/deposit/addEdit.action", "/channel/add.action"}, logical = Logical.OR)
//    @ResponseBody
//    public ResponseDTO<String> inOutDeposit(Integer channelId, Integer type, Double amount, String remark) {
//
//        String typeStr = Objects.equals(type, 1) ? "收退款" : (Objects.equals(type, 2) ? "收退款" : "扣除");
//
//        String label = typeStr + "押金";
//        try {
//            LoginStaff mcStaff = getMcStaff();
//            // 元转分
//            int amountFen = NumberUtil.convertMoneyToFen(amount.toString());
//            channelBService.inOrOutDeposit(channelId, type, amountFen, mcStaff.getRealName(), remark);
//
//            return ResponseDTO.success(String.valueOf(channelId), String.format("%s成功！", label));
//
//        } catch (PlatException e) {
//            return ResponseDTO.fail(e.getMessage());
//        } catch (Exception e) {
//            logger.error("error:", e);
//            return ResponseDTO.fail(String.format("%s失败！", label));
//        }
//    }
//
//    @RequestMapping("addEditRatio")
//    @ResponseBody
//    public ResponseDTO addEditRatio(@RequestBody ChannelCityPriceRatioVo channelCityPriceRatioVo) {
//        try {
//            String realName = getMcStaff().getRealName();
//            channelBService.modifyChannelRatio(channelCityPriceRatioVo, realName);
//            return ResponseDTO.success(StatusConsts.STATUS_SUCCESS, "操作成功！");
//        } catch (org.springframework.dao.DuplicateKeyException ex) {
//            logger.error("渠道价格系数【{}】已经存在，不能重复添加！", channelCityPriceRatioVo.getChannelId());
//            return ResponseDTO.fail("渠道价格系数已经存在，不能重复添加！");
//        } catch (Exception ex) {
//            logger.error("[zmn]新增/修改渠道价格系数失败,baseCityPriceRatio:[{}],ex:", JSONObject.toJSONString(channelCityPriceRatioVo), ex);
//            return ResponseDTO.fail("操作失败！");
//        }
//    }
//
//    @RequestMapping("addEditDiscount")
//    @ResponseBody
//    public ResponseDTO addEditDiscount(@RequestBody ChannelCityPriceRatio channelCityPriceRatio) {
//        try {
//            String realName = getMcStaff().getRealName();
//            channelBService.modifyChannelDiscount(channelCityPriceRatio, realName);
//            return ResponseDTO.success(StatusConsts.STATUS_SUCCESS, "操作成功！");
//        } catch (org.springframework.dao.DuplicateKeyException ex) {
//            logger.error("渠道折扣系数【{}】已经存在，不能重复添加！", channelCityPriceRatio.getChannelId());
//            return ResponseDTO.fail("渠道折扣系数已经存在，不能重复添加！");
//        } catch (Exception ex) {
//            logger.error("[zmn]新增/修改渠道折扣系数失败,baseCityPriceRatio:[{}],ex:", JSONObject.toJSONString(channelCityPriceRatio), ex);
//            return ResponseDTO.fail("操作失败！");
//        }
//    }
//
//    /**
//     * 复制渠道系数
//     *
//     * @param sourceChannelId
//     * @param targetChannelId
//     * @param bizType
//     * @param priceType
//     * @param copyRatioType
//     * @author linfeng
//     * @since 2020-03-19 18:23:38
//     */
//    @RequestMapping(value = "copyChannelRatio")
//    @ResponseBody
//    public ResponseDTO copyChannelRatio(HttpServletRequest request,
//                                        @RequestParam(value = "sourceChannelId", defaultValue = "0") Integer sourceChannelId,
//                                        @RequestParam(value = "targetChannelId", defaultValue = "0") Integer targetChannelId,
//                                        @RequestParam(value = "bizType") Integer bizType, @RequestParam(value = "priceType") Integer priceType,
//                                        @RequestParam(value = "effectiveDate") String effectiveDate, @RequestParam(value = "copyRatioType") String copyRatioType) {
//
//        if (sourceChannelId == 0) {
//            return ResponseDTO.fail("源渠道ID不能为空！");
//        }
//        if (targetChannelId == 0) {
//            return ResponseDTO.fail("目标渠道ID不能为空！");
//        }
//        if (NumberUtil.isNullOrZero(bizType)) {
//            return ResponseDTO.fail("bizType类型不能为空！");
//        }
//        if (NumberUtil.isNullOrZero(priceType)) {
//            return ResponseDTO.fail("价格类型不能为空！");
//        }
//        if (StringUtil.isBlank(copyRatioType)) {
//            return ResponseDTO.fail("选择复制的系数类型不能为空！");
//        }
//
//        List<Integer> ratioTypes = new ArrayList<>();
//        if (copyRatioType.indexOf(channelDiscountRatioType) != -1) {
//            ratioTypes.add(ChannelCityRatioTypeEnum.DISCOUNTRATIO.getCode());
//        }
//        if (copyRatioType.indexOf(channelCityRatioType) != -1) {
//            ratioTypes.add(ChannelCityRatioTypeEnum.CHANNELRATIO.getCode());
//            ratioTypes.add(ChannelCityRatioTypeEnum.CHANNELCITYRATIO.getCode());
//            ratioTypes.add(ChannelCityRatioTypeEnum.CHANNELCITYCATEGONERATIO.getCode());
//            ratioTypes.add(ChannelCityRatioTypeEnum.CHANNELCITYCATEGTWORATIO.getCode());
//        }
//
//        if (CollectionUtil.isNotNullOrEmpty(ratioTypes)) {
//            Date date = DateUtil.parse(effectiveDate, DateUtil.FORMAT_DATE);
//            channelCityPriceRatioBService.copyRatio(sourceChannelId, targetChannelId, bizType, priceType, date, ratioTypes,
//                    getMcStaff().getRealName());
//        }
//
//        if (copyRatioType.indexOf(channelBrandRatioType) != -1) {
//            Date date = DateUtil.parse(effectiveDate, DateUtil.FORMAT_DATE);
//            channelBrandRatioBService.copyRatio(sourceChannelId, targetChannelId, bizType, priceType, date, getMcStaff().getRealName());
//        }
//
//        return ResponseDTO.success(GlobalConsts.SUCCESS_MSG, "操作成功！");
//    }
//
//    /**
//     * 描述: 加载该渠道下的服务分类
//     *
//     * @param channelId 渠道id
//     * @param showType  产品类型
//     * @return java.util.List<com.zmn.common.dto.VtDTO>
//     * @author wangjie
//     * @since 2019/9/25
//     **/
//    @RequestMapping("loadServByShowType")
//    @ResponseBody
//    public List<VtDTO> loadServByShowType(@RequestParam(value = "showType", defaultValue = "0") Integer showType,
//                                          @RequestParam(value = "channelId", defaultValue = "0") Integer channelId) {
//
//        return Optional.ofNullable(super.getServCategoryList()).orElse(Collections.emptyList()).stream().map(mm -> {
//            VtDTO vtDTO;
//            if (Objects.equals(showType, ProductDict.ERP_PRODUCT_TYPE)) {
//                vtDTO = new VtDTO(mm.getCategId(), mm.getName(), mm.getStatus());
//            } else {
//                vtDTO = new VtDTO(mm.getCategId(), mm.getShowName(), mm.getStatus());
//            }
//            return vtDTO;
//        }).collect(Collectors.toList());
//    }
//
//}
